package cn.kengtion.shopcart.Presenter;

import java.util.List;

import cn.kengtion.shopcart.Bean.GoodBean;
import cn.kengtion.shopcart.Listener.AbsMsgListener;
import cn.kengtion.shopcart.Model.CartModel;
import cn.kengtion.shopcart.Model.CartModelImpl;
import cn.kengtion.shopcart.View.CartView;

/**
 * 创建时间 2017/10/30
 * 创建人 洪坤峰
 * 功能描述：
 */

public class CartPresenterImpl implements CartPresenter, CartModelImpl.CartDataListener {
    private CartView view;
    private CartModel cartModel;
    public CartPresenterImpl(CartView view) {
        this.view = view;
        cartModel = new CartModelImpl(this);
    }


    @Override
    public void getGoodsList() {
        cartModel.getGoodsList();
    }

    @Override
    public void setMsgListener(AbsMsgListener listener) {
        cartModel.setMsgListener(listener);
    }

    @Override
    public void addGoods(String goodId) {
        cartModel.addGoods(goodId);
    }

    @Override
    public void errorOccured(String error) {
        view.showErrorMsg(error);
    }

    @Override
    public void GoodsDataChanged() {
        view.notifyDatasetChanged();
    }

    @Override
    public void getGoodsList(List<GoodBean> goodBeans) {
        view.showGoodsList(goodBeans);
    }
}
